{extend name="common@create" /}
{block name="mycss"}
{css href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.css" /}
{/block}
{block name="formaa"}
	<div class="form form-horizontal text-c">
		<img id='rypic' width="400px" src="__UPLOAD__/keti/lixiang/{$list.lxpic}">
	</div>
	<form action="/ktinfo/{$list.id}" method="PUT" class="form form-horizontal" id="form-member-add">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>课题名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$list.title}" placeholder="课题册标题" id="title" name="title">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>主持人：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text mb-10" value="" placeholder="主持人(姓名、首拼、全拼" id="hjteacher" name="hjteacher" style="max-width: 200px;min-width: 80px" onkeyup="hjSelect(this)">
				<div id="addHj"> 
					{volist name="list.kt_zcr" id="vo"}
					<span>
						<input type="hidden" value="{$vo.teacherid}" name="hjteachers[]">
						<input class="btn btn-success radius mr-5 size-MINI" type="button" value="{$vo.teacher.xingming}" onclick="delCy(this)">
					</span>
					{/volist}
				</div>
				<div id="hjSelect"></div>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>课题编号：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="{$list.bianhao}" placeholder="课题编号" id="bianhao" name="bianhao">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>负责单位：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l" style="width:300px;">
				{php} $school = schlist('校级','区级');{/php}
				<select class="select" id="fzdanweiid" name="fzdanweiid" size="1" required>
					<option value="">--请选课题负责单位--</option>
					{volist name="school" id="vo"}
						<option value="{$vo.id}" {eq name="$list.fzdanweiid" value="$vo['id']" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>学科分类：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l" style="width:180px;">
				{php}$category = getCategory(116);{/php}
				<select class="select" id="subject" name="subject" style="width: 350px" size="1" required>
					<option value="">--请选择课题研究所属学科分类--</option>
					{volist name="category" id="vo"}
						<option value="{$vo.id}" {eq name="$list.subject" value="$vo['id']" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>研究类型：</label>
			<div class="formControls col-xs-8 col-sm-9 f-l">
				<span class="select-box f-l" style="width:200px;">
				{php}$category = getCategory(117);{/php}
				<select class="select" id="category" name="category" size="1" required>
					<option value="">--请选择课题研究类型--</option>
					{volist name="category" id="vo"}
						<option value="{$vo.id}" {eq name="$list.category" value="$vo['id']" }selected{/eq}>{$vo.title}</option>
					{/volist}
				</select>
				</span>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>计划结题时间：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text Wdate" value="{$list.jhjtshijian}" placeholder="" id="jhjtshijian" name="jhjtshijian" onclick="WdatePicker({isShowClear:false,readOnly:true})" style="width:150px;">
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
{/block}
{block name="yanzheng"}
{js href="/static/H-ui.admin_v3.1.3.1/H-ui.admin/lib/webuploader/0.1.5/webuploader.js"}
<script type="text/javascript">

	// 设置表单验证规则
	var myrules = {
			title:{
				required:true,
				maxlength:60,
			},
			bianhao:{
				required:true,
				rangelength:[1,10]
			},
			jhjtshijian:{
				dateISO:true
			},
		};

	// 设置表单提交方式
	var mytype = 'PUT';


	// 获取课题主持教师列表
	function hjSelect(obj)
	{
		$('#hjSelect').empty();
		var str = "";
		str = $('#hjteacher').val();
		if(str.length<=0)
		{
			return "";
		}
		$.post(
			"{:Url::build('renshi/index/srcTeacher')}",
			{
				"str":str,
			},
			function(data,status){
				$('#hjSelect').empty();
				if($.isEmptyObject(data))
				{
					return true;
				}
				for (var i = data.length - 1; i >= 0; i--) {
					var myhtml = "";
					myhtml = "<input class='btn btn-secondary radius mr-5 size-MINI' type='button' value='" + data[i]['xingming'] + "' onclick=addHj(this,"+data[i]['id']+") title="+data[i]['js_danwei']['jiancheng']+'　'+data[i]['sex']+'　'+data[i]['age']+" >";
					$('#hjSelect').append(myhtml);
				}
				
			}
		);
	}

	// 添加参与人
	function addHj(obj,teacherId)
	{
		$('#hjteacher').val('');
		$(obj).attr('class','btn btn-warning radius mr-5 size-MINI');
		$(obj).attr('onclick','delCy(this)');
		var myhtml = "";
		myhtml = "<span><input type='hidden' name='hjteachers[]' value ="+teacherId+"></span>";
		$('#addHj').append(myhtml);
		$('#addHj').children("span").last().append(obj);
	}

	// 删除参与人
	function delCy(obj)
	{
		$(obj).parent().remove();
	}
	

	// 匹配用户名
	$.validator.addMethod("zh",function(value,element){
		var tel = /^[\u4e00-\u9fa5]*$/;
		return this.optional(element) || tel.test(value);
	}, "请输入中文");

	

	
</script>
{/block}